package TestHeap;
import java.util.Comparator;
import java.util.PriorityQueue;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 86183
 * Date: 2024-05-23
 * Time: 11:18
 */
class Person implements Comparable<Person>{
    public int age;
    public String name;

    public Person(int age, String name) {
        this.age = age;
        this.name = name;
    }

    @Override
    public String toString() {
        return "Person{" +
                "age=" + age +
                ", name='" + name + '\'' +
                '}';
    }

    @Override
    public int compareTo(Person o) {
        return o.age- this.age;
    }

}
class NameComparator implements Comparator<Person>{
    @Override
    public int compare(Person o1, Person o2) {
        return o2.name.compareTo(o1.name);
    }
}
class AgeComparator implements Comparator<Person>{
    @Override
    public int compare(Person o1,Person o2) {
        return o2.age-o1.age;
    }
}
public class Test {
    public static void main(String[] args) {
        PriorityQueue<Person> priorityQueue = new PriorityQueue<>(new AgeComparator());
        priorityQueue.offer(new Person(12,"zhangshan"));
        priorityQueue.offer(new Person(10,"liss"));
        System.out.println();

    }
    public static void main2(String[] args) {
        PriorityQueue<Integer> priorityQueue = new PriorityQueue<>();
        priorityQueue.offer(10);
        priorityQueue.offer(2);
        System.out.println(priorityQueue.poll());
    }
    public static void main1(String[] args) {
        int[] array = {27,15,19,18,28,34,64,49,25, 37};

        TestHeap testHeap = new TestHeap();
        testHeap.initElem(array);
        testHeap.createBigHeap();
      //  testHeap.poll();
        testHeap.offer(80);
        System.out.println("=============");

    }
}

